package com.peng.my_blog.api.service;

import com.peng.my_blog.api.entity.User;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @author wangshipeng
 * @Description:
 * @date 2019-03-15 15:34
 */
@FeignClient(value = "article-service", fallback = UserService.UserServiceFallback.class)
public interface UserService {
    @RequestMapping(value = "/user/getUserInfoById",method = RequestMethod.GET)
    User getUserInfoById(@RequestParam("id") Integer id);

    @Component
    class UserServiceFallback implements UserService {
        @Override
        public User getUserInfoById(Integer id) {
            System.out.println("触发feign-fallback");
            return null;
        }
    }
}
